export default {
	namespaced: true,
	state: () => ({
		addressList: [], //地址薄列表
		carResult: {
			numberplate: "",
			vehicleType: "",
			brandModel: "",
			specification: "",
			carriageLength: "",
			loadSide: "",
			vehicleHeight: "",
			loadCapacity: "",
			highRoof: false,
			categoryId: ''
		},
		model: {
			licensePhoto: "",
			driverPhoto: "",
			idCardFront: "",
			idCardBack: "",
			drivingLicense: "",
			drivingLicenseCar: "",
			carFortyFive: "",
			roadTransport: '',
			ismodify: true
		},
	}),
	mutations: {
		//图片数据
		addModel(state, data) {
			for (let k in state.model) {
				state.model[k] = data[k]
			}
			if (data.certStatus.value == 1) {
				state.model.ismodify = false
			} else {
				state.model.ismodify = true
			}
		},
		//车辆规格选择
		CarTypeCange(state, data) {
			state.carResult.specification = data.carResult.specification
		},
		//车辆类型选择
		vehicleCange(state, data) {
			state.carResult.categoryId = data.categoryId
			state.carResult.vehicleType = data.vehicleType
			state.carResult.specification = data.specification
		},
		//车辆信息
		addCarResult(state, data) {
			for (let k in state.carResult) {
				state.carResult[k] = data[k]
			}
			if (data.vehicleInfoVos) {
				if (data.vehicleInfoVos.length > 0) {
					var resultDate = data.vehicleInfoVos[0];
					resultDate.specification = JSON.parse(resultDate.specification)
					state.carResult.numberplate = resultDate.numberplate
					state.carResult.brandModel = resultDate.brandModel
					state.carResult.specification = resultDate.specification
					state.carResult.vehicleType = resultDate.vehicleType
					state.carResult.carriageLength = resultDate.carriageLength
					state.carResult.loadCapacity = resultDate.loadCapacity
					state.carResult.loadSide = resultDate.loadSide
					state.carResult.vehicleHeight = resultDate.vehicleHeight
				}
			}
		},
		//选择车辆类型
		renewDriverResult(state, data) {
			state.driverResult.licenseLevel = data.licenseLevel
			state.driverResult.licenseValue = data.licenseValue
		},
		//图片新增
		Photos(state, data) {
			state.model[data.imgname] = data.url
		},
		//修改地址薄
		getAddressList(state, data) {
			state.addressList = data
		},
	},
	actions: {
		//获取地址薄地址
		async search_addr_book(context, data) {
			const {
				data: res
			} = await this.$http.address.search_addr_book(data)
			if (res.success) {
				context.commit('getAddressList', res.data)
			}
		}
	}
}